package com.westar.base.exceptions;

/**
 * 登录异常信息
 */
public class SelfHttpException extends Exception {

    public static Integer PAGE_NOT_FOUND = 404;

    public static Integer PAGE_RE_LOGIN = 30201;

    public static Integer LOGIN_ERROR = 30202;

    public static Integer UNKNOMN_ERROR = 500;
    /**
     * 异常信息
     */
    protected String msg;
    /**
     * 具体异常码
     */
    protected Integer code;

    public SelfHttpException(Integer code, String msgFormat, Object... args) {
        super(String.format(msgFormat, args));
        this.code = code;
        this.msg = String.format(msgFormat, args);
    }

    public SelfHttpException() {
        super();
    }

    public String getMsg() {
        return msg;
    }

    public Integer getCode() {
        return code;
    }

    /**
     * 实例化异常
     *
     * @param msgFormat
     * @param args
     * @return
     */
    public SelfHttpException newInstance(String msgFormat, Object... args) {
        return new SelfHttpException(this.code, msgFormat, args);
    }

    public SelfHttpException(String message, Throwable cause) {
        super(message, cause);
    }

    public SelfHttpException(Throwable cause) {
        super(cause);
    }

    public SelfHttpException(String message) {
        super(message);
    }
}
